package cn.dzhang.spring.boot.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;

import cn.dzhang.spring.boot.model.Role;
import cn.dzhang.spring.boot.model.User;
import cn.dzhang.spring.boot.repository.RoleRepository;
import cn.dzhang.spring.boot.service.JpaAdapter;
import cn.dzhang.spring.boot.service.RoleService;

@Service
public class RoleServiceImpl extends JpaAdapter<Role, Integer> implements
		RoleService {

	@Autowired
	private RoleRepository repository;

	@Override
	protected JpaRepository<Role, Integer> getRepository() {
		return repository;
	}

	@Override
	public List<Role> findByUser(User user) {
		return repository.findByUserId(user.getId());
	}
}
